<?
//引入所有子系统信息
include_once("../../../common/model/extender_import.php");
//引入系统设置
include_once("../../../common/model/setting.php");




$limit_day=date("Y-m-d",strtotime("+10 day"));

//查询临近到期的联系人，自己所属
$member_contact=select_lines_all_items($table_prefix."member","checkpoint asc",
                                       "agentnid = '".$_SESSION['nid']."' and checkpoint < '$limit_day'",
                                       "");


//查询所有客户总数
$p['item']="nid";
$p['table']=$table_prefix."member";
$p['condition']="1 = 1";
$member_number=count_number($p);


//查询运单数
$p['item']="nid";
$p['table']=$table_prefix."order";
$p['condition']="status != '作废'";
$order_number=count_number($p);


//获取本页用到的单位的名字
$unit_nid_list=transform_2darray_in_1darray_with_new_key($member_contact,"nid","unitnid");
$unit_nid_list_str=implode("','",$unit_nid_list);
$unit_list=select_lines_all_items($table_Prefix."unit","","nid in ('".$unit_nid_list_str."')","");
$unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","sname");




//订单信息
$orderlist = select_lines_all_items($table_prefix . "order_list", "", "date like '" . date("Y-m-d") . "%'", "");



?>




<?

//读取临近的续费信息
$start_date=date('Y-m-d', strtotime ("+15 day", strtotime(date("Y-m-d h:i:s"))));
$renewal_list=select_lines_all_items($table_prefix."renewal","","status ='进行中' and next_enddate <'".$start_date."'" ,"");





//读取要跟踪的客户
$checkpoint_days=date('Y-m-d', strtotime ("+5 day", strtotime(date("Y-m-d h:i:s"))));
$member_checkpoint=select_lines_all_items($table_prefix."member","","checkpoint <'".$checkpoint_days."' and checkpoint != '' and period !='无限制'","");




//读取有东西超时的项目
$case_checkpoint_days=date('Y-m-d', strtotime ("+5 day", strtotime(date("Y-m-d h:i:s"))));
$case_checkpoint=select_lines_all_items($table_prefix."case","","(expect_startdate <'".$case_checkpoint_days."' or
                                                                  expect_enddate <'".$case_checkpoint_days."' or
                                                                  expect_paydate <'".$case_checkpoint_days."')
                                                                  and expect_startdate != '0000-00-00 00:00:00'
                                                                  and expect_enddate != '0000-00-00 00:00:00'
                                                                  and expect_paydate != '0000-00-00 00:00:00'
                                                                  and status ='进行中' and paydate < 1
                                                                  ","");






//员工 未做数据筛选。全部都显示
$employee_list = select_lines_all_items($table_Prefix . "employee", "nid desc", "", "0");
$employee_list_1d_array=transform_2darray_in_1darray_with_new_key($employee_list,"nid","name");
//print_r2($member_checkpoint);


//获取本页用到的单位的名字
$unit_nid_list=transform_2darray_in_1darray_with_new_key($member_checkpoint,"nid","unit");
//print_r2($unit_nid_list);
$unit_nid_list_str=implode("','",$unit_nid_list);
$unit_list=select_lines_all_items($table_prefix."unit","","nid in ('".$unit_nid_list_str."')","");
$unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","sname");

//print_r2($unit_name_list);

?>








